package com.cn.zengzeng.spbzengzeng;

import com.alibaba.fastjson.parser.ParserConfig;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
import org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;

@SpringBootApplication(exclude={
        RedisAutoConfiguration.class,
        RedisRepositoriesAutoConfiguration.class})
@MapperScan(basePackages = {"com.cn.zengzeng.spbzengzeng.mapper"})
@EnableScheduling
@EnableAsync
@Slf4j
public class SpbZengzengApplication implements CommandLineRunner {
    public static void main (String[] args) {
//        Unirest.config().connectTimeout(60000).socketTimeout(20000);
        log.info("lozenge--启动开始");
        //开启autoType 安全模式
        ParserConfig.getGlobalInstance().setSafeMode(true);
        SpringApplication.run(SpbZengzengApplication.class,args);
        log.info("启动成功");

        //返回Java虚拟机中的堆内存总量
        long xmsMemory = Runtime.getRuntime().totalMemory() / 1024 / 1024;
        //返回Java虚拟机中使用的最大堆内存
        long xmxMemory = Runtime.getRuntime().maxMemory() / 1024 / 1024;
        System.out.println("-Xms:" + xmsMemory + "M");
        System.out.println("-Xmx:" + xmxMemory + "M");
        //        System.out.println("系统内存大小为:" + xmsMemory * 64.0 / 1024 + "G");
        //        System.out.println("系统内存大小为:" + xmxMemory * 4.0 / 1024 + "G");
        //        在使用 -Xms500m -Xmx500m -XX:+PrintGCDetails需要把等待时间代码注释掉
        //        try {
        //            Thread.sleep(1000000);
        //        } catch (InterruptedException e) {
        //            e.printStackTrace();
        //        }
    }


    @Override
    public void run (String... args)  {
        log.info("预加载");
    }
}
